package com.ncu.controller;

import com.ncu.pojo.Dept;
import com.ncu.pojo.Msg;
import com.ncu.service.DeptService;
import com.ncu.service.impl.DeptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class DeptController {

    @Autowired
    private DeptService deptService;


    @RequestMapping("/findDept")
    @ResponseBody
    public Msg findAllDept(HttpServletResponse response){
        Msg msg=new Msg();
        List<Dept> allDept = deptService.findAllDept();
        Map<String,Object> map=new HashMap<>();
        map.put("AllDept",allDept);
        int status = response.getStatus();
        msg.setDate(status);
        msg.setDate(1);
        msg.setMap(map);
        return msg;
    }
}
